#coding=utf-8
#!/usr/bin/python

'''
Created on 2012-11-17

@author: Neo.Chen
'''
import os

#-------------------------------------------------------------------------------
def psstringToList(ps_string):
    lineList = []
    try:
        line_arr = [""]
        if len(ps_string) > 2:
            line_arr = ps_string.split('\n')
            for line_item in line_arr:
                if len(line_item) > 2:
                    attr_arr = [""]
                    attr_arr = line_item.split(' ')
                    curPid = 0
                    attrList = []
                    for attr_item in attr_arr:
                        if len(attr_item) > 0 and attr_item != " ":
                            attrList.append(attr_item)
                lineList.append(attrList)
    except:
        print("psstringToList except")
    return lineList

#-------------------------------------------------------------------------------
def execcmd(cmd):
    lineList = []
    ps_string = ""
    try:
        ps_string = os.popen(cmd,'r').read()
    except:
        print("popen except")
    print("execcmd, ps_string:"  + ps_string)
    lineList = psstringToList(ps_string)
    return lineList


#-------------------------------------------------------------------------------
def main():
    lineList = []
    #cmd = 'ps lax | grep vcs_test | grep -v grep'
    #lineList = execcmd(cmd)
    #print(lineList)
    lineList = psstringToList("root     20593 99.5  0.0   2772   116 pts/8    R+   16:50  84:47 ./vcs_test")

if __name__ == '__main__':
    main()



















